//测试连接心跳. 用telnet 客户端，断网线测试就可以了

#include "stdafx.h"
#include "version.h"
#include "unit_test.h"
#include "log_file.h"
#include "include_all.h"
#include <stdlib.h>

using namespace std;
using namespace lc;

static const uint16 PORT = 15532;

class Connect2Client : public lc::SvrCon
{
public:
	~Connect2Client()
	{
		LB_DEBUG("disconnect %ld", GetId());
	}
private:
	virtual void OnRecv(const lc::MsgPack& msg) override
	{
		LB_DEBUG("OnRecv %s", &msg.data);
		SendData(msg);
	}
	virtual void OnConnected() override
	{
		LB_DEBUG("OnConnected");
	}
};


DefaultLog my_log("log_keepalive.txt");
int main(int argc, char* argv[]) 
{
	LogMgr::Ins().SetLogPrinter(my_log);

	LB_DEBUG("start server");
	Listener<Connect2Client> listener;
	listener.Init(PORT);
	EventMgr::Ins().Dispatch();
	LB_DEBUG("-----------end------------");
	return 0;
}

